<?php
/*
 * @Author: lokei
 * @Date: 2022-09-17 16:25:29
 * @LastEditors: lokei
 * @LastEditTime: 2022-09-18 17:04:10
 * @Description: 
 */
namespace App\Http\Controllers\Platform\Tag;

use App\Common\Tools\ResultTool;
use App\Http\Controllers\Controller;
use App\Models\Platform\Tag\TagModel;
use Illuminate\Http\Request;

class TagController extends Controller {
    public function list() {
        $items = TagModel::get();
        $res = ResultTool::success();
        $res['data']['items'] = $items;
        $res['data']['total'] = count($items);
        return $res;
    }

    public function ofScene(Request $request) {
        $items = TagModel::where('scene', '=', $request->input('scene'))->get();
        $res = ResultTool::success();
        $res['data']['items'] = $items;
        $res['data']['total'] = count($items);
        return $res;
    }

    public function create(Request $request) {
        $tag = new TagModel();
        $tag->scene = $request->input('scene');
        $tag->name = $request->input('name');
        $tag->img_thumb = $request->input('img_thumb');
        $tag->save();
        return ResultTool::success();
    }
}